#include "TestBuildSelf.hpp"
#include "../LibBuildNG/LibBuildNG.hpp"

#include <glibmm.h>
#include <direct.h>

namespace BuildNG
{
  TestBuildSelfWorkspace::TestBuildSelfWorkspace(const Glib::ustring &root_dir)
  {
    g_mkdir_with_parents(root_dir.c_str(),0755);
    _chdir(root_dir.c_str());

    // check out the code
    Glib::spawn_command_line_sync("bzr branch lp:buildng");
    
    _chdir("buildng");
    _chdir("src");
  }

  void TestBuildSelfWorkspace::test_build_shared()
  {
    _chdir("Shared");

    Glib::RefPtr<BuildNG::Project> project = BuildNG::Project::load_from_file("Shared.buildng");
    bool build_res = project->build("../out",BuildNG::StdErrorListener::create());
    assert(build_res);
  }
}